Android article,Different types of notifications in Android systems
نوشته شده توسط : dotnek

They design notifications to remind users of important things so that users can be informed of important things. Notifications can also include text, titles, buttons, styles, images, or icons. There are different types of notifications , which we will discuss in this section of educational articles.Notifications are in fact the notification windows that inform users of important things. It should be noted that notifications are initially displayed as icons in the Status Bar that if the user pulls the bar down and Notification Drawer opens the notification will be displayed in full. Notifications can be generated and displayed during the day, so there is no need to run the program, and even if the program is not running, the relevant notification will appear. It should be noted that even notifications can be displayed on the lock screen and can be displayed from there.As mentioned, there are different types of notifications and they can be created using different methods. Some of them can be simple or complex, with images, icons, text, title, buttons, and so on. For example, we can use PendingIntent to define an operation that can be performed by the user after touching the notification.1- We create a new project in Android Studio with the desired name Notification.2- The activity used in this project is better to be selected as Empty Activity.3- Add a Button to the activity_main.xml file.

Note:

Layers have been changed to LinearLayout for easy management.

<? xml version = "1.0" encoding = "utf-8"?>
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
xmlns: app = "http://schemas.android.com/apk/res-auto"
xmlns: tools = "http://schemas.android.com/tools"
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: orientation = "vertical"
android: gravity = "center"
tools: context = ". MainActivity">

<Button
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: id = "@ + id / simple_notif"
android: text = "Simple Notification" />

</LinearLayout>
The code written inside MainActivity.java is as follows:
package com.dotnek. Notification;

import androidx.appcompat.app. AppCompatActivity;
import androidx.core.app. NotificationCompat;
import android.app. NotificationManager;
import android. content. Context;
import android.os. Bundle;
import android. view. View;
import android. widget. Button;

public class MainActivity extends AppCompatActivity {

Button simpleButton;
NotificationManager notifManager;

@Override
protected void onCreate (Bundle savedInstanceState) {
super. onCreate (savedInstanceState);
setContentView (R. layout. activity_main);

simpleButton = findViewById (R.id. simple_notif);

notifManager = (NotificationManager) getSystemService (Context.NOTIFICATION_SERVICE);

simpleButton.setOnClickListener (new View.OnClickListener () {
@Override
public void onClick (View view) {
simpleNotification ();
}
});

}

public void simpleNotification () {

NotificationCompat.Builder sNotifBuilder = new NotificationCompat.Builder (this)
. setSmallIcon (R. drawable. notif_icon)
. setContentTitle ("Update")
. setContentText ("A new version of the application is ready to download");

notifManager.notify (1, sNotifBuilder.build ());

}

}
By inserting the above code into the MainActivity class, we create a Button called simpleButton and an object from the NotificationManager method called notifManager. Then we define these two in onCreate. 

Read more on:https://www.dotnek.com/Blog/Apps/different-types-of-notifications-in-android-s

link:Search engine Optimization (SEO services)

Related link:https://dotnek.mystrikingly.com/





:: برچسب‌ها: dotnek , seo , site ,
:: بازدید از این مطلب : 123
|
امتیاز مطلب : 10
|
تعداد امتیازدهندگان : 2
|
مجموع امتیاز : 2
تاریخ انتشار : سه شنبه 19 مرداد 1400 | نظرات ()
مطالب مرتبط با این پست
لیست
می توانید دیدگاه خود را بنویسید


نام
آدرس ایمیل
وب سایت/بلاگ
:) :( ;) :D
;)) :X :? :P
:* =(( :O };-
:B /:) =DD :S
-) :-(( :-| :-))
نظر خصوصی

 کد را وارد نمایید:

آپلود عکس دلخواه: